package net.xdclass.mapper;

import net.xdclass.entity.Coupon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lixin
 * @since 2024-08-23
 */
public interface CouponMapper extends BaseMapper<Coupon> {

    /**
     * 扣减库存
     * @param couponId
     * @return
     */
    @Update("update coupon set stock = stock - 1 where id = #{couponId} and stock > 0")
    int reduceStock(long couponId);

}
